package com.qingmeng.project.service.impl.Inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qingmeng.apicommon.model.entity.InterfaceInfo;
import com.qingmeng.apicommon.model.entity.User;
import com.qingmeng.apicommon.service.InnerInterfaceInfoService;
import com.qingmeng.apicommon.service.InnerUserInterfaceInfoService;
import com.qingmeng.project.common.ErrorCode;
import com.qingmeng.project.exception.BusinessException;
import com.qingmeng.project.mapper.InterfaceInfoMapper;
import com.qingmeng.project.service.InterfaceInfoService;
import com.qingmeng.project.service.UserInterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {

    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;
    /**
     * 查询用户访问接口是否存在
     * @param path
     * @param method
     * @return
     */
    @Override
    public InterfaceInfo isInvokeMock(String path, String method) {
        if (StringUtils.isAnyBlank(path,method)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<InterfaceInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("url", path)
                .eq("request_type", method);
        return interfaceInfoMapper.selectOne(queryWrapper);
    }
}
